<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
            
    <script type="text/javascript">
    <!-- 
    $(document).ready(function() {
    	$("#doSaveBtn").click(function() {
    		var createUserId = $('#createUserId').val();//使用者ID
    		var createUserName = $('#createUserName').val();//姓名
    		var createUserPhoneNo = $('#createUserPhoneNo').val();//電話
    		var createUserEmail = $('#createUserEmail').val();//E-MAIL
    		var createCertificateKey = $("#createCertificateKey").val();//憑證序號 	
    		var createUserNote = $('#createUserNote').val();//備註
    		var value1 = createUserId.replace(/^\s+|\s+$/g,'');
    		var value2 = createUserName.replace(/^\s+|\s+$/g,'');
    		var value3 = createUserPhoneNo.replace(/^\s+|\s+$/g,'');
    		var value4 = createUserEmail.replace(/^\s+|\s+$/g,'');
    		var value5 = createCertificateKey.replace(/^\s+|\s+$/g,'');
    		var value6 = createUserNote.replace(/^\s+|\s+$/g,'');
    		var emailRegExp = /[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/;
			var createUserPhoneNoRegExp = /^0[0-9]{1,3}\-\d{5,8}$/;
			var flag = true;
    		var errorMessage = '';
    		
    		if (value1.length <= 0){
    			errorMessage = '使用者ID不可空白!!';
    		} else {
    			var count = createUserId.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(createUserId.charCodeAt(i) < 0 || createUserId.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 20){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '使用者ID不可超過20碼!!';
				 }
    		}
    		
    		if (value2.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + '姓名不可空白!!';
    		} else {
    			var count = createUserName.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(createUserName.charCodeAt(i) < 0 || createUserName.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 50){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '姓名不可超過50碼!!';
				 }
    		}
    		
    		if(value3.length > 0){
    			if(!createUserPhoneNoRegExp.test(value3)){
    				if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '[電話號碼]格式錯誤,格式為0x-xxxxxxxx!!';
    			}
    		}
    		
    		if (value4.length <= 0){
    			if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + 'E-MAIL不可空白!!';
    		} else {
    			if(!emailRegExp.test(createUserEmail)){
    				if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    errorMessage = errorMessage + '[E-MAIL]格式錯誤!!';
    			}else{
    				var count = createUserEmail.length;
					 var strLength = 0;					 
					 for(var i = 0; i < count; i++){
						  if(createUserEmail.charCodeAt(i) < 0 || createUserEmail.charCodeAt(i) > 255){
						   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
						  }else{
						  	 strLength += 1;
						  }
					 }
					 if(strLength > 100){
					 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
	    		    	 errorMessage = errorMessage + 'E-MAIL不可超過100碼!!';
					 }
    			}
    			
    		}
    		
    		if (value5.length > 0)
   		 {  			
   				var count = createCertificateKey.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(createCertificateKey.charCodeAt(i) < 0 || createCertificateKey.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 30){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '憑證序號不可超過30碼!!';
				 }
    		}
    		
    		if (value6.length > 0)
    		{
    			 var count = createUserNote.length;
				 var strLength = 0;					 
				 for(var i = 0; i < count; i++){
					  if(createUserNote.charCodeAt(i) < 0 || createUserNote.charCodeAt(i) > 255){
					   	strLength += 3;//漢字編碼在0-255之外，oracle數據庫是UTF-8編碼，一個漢字，對應數據庫varchar2的3個byte。
					  }else{
					  	 strLength += 1;
					  }
				 }
				 if(strLength > 100){
				 	 if (errorMessage != '') errorMessage = errorMessage + '<br>';
    		    	 errorMessage = errorMessage + '備註不可超過100碼!!';
				 } 			
    		}  
    		
            if (errorMessage != '')
            {	
            	flag = false;
                showErrorMessageDialog(errorMessage);
            }
           
    		if(flag){
    			return true;
    		}else{
    			return false;
    		}
		});
		
		/* 用戶群組（GROUP）下拉選單的值改變事件 */
		$('#qrySelectGroup').change(function() {
            $('#qrySelectGroupBtn').click();
		});
		
		//全選 
      $('#checkboxAll').click(function() 
        {
         var chk = $('#checkboxAll').attr('checked');   			
         $('#queryUserForm input:checkbox').each(function(){  
         
         if("checked"==chk){ 
    		 $(this).attr('checked', chk);
    		}  				
    	else{
			 $(this).removeAttr('checked');
    		}
           });
        });
         
		//取消
		$("#doCancelBtn").click(function() {
			$("#hidden\\.doCancelBtn").trigger('click');
		});
		
		
		<c:if test="${not empty actionBean.message}">
   			showMessageDialog('<c:out value="${actionBean.message }" escapeXml="false"/>');
		</c:if>	
    });
    
    //-->
    </script>
</head>
<body>
	<div id="smallQueryForm"></div>
	<stripes:form id="queryUserForm" beanclass="com.feib.stms.action.Stms9006ActionBean" method="post">
	<div id="queryForm">
		<table>
			<tr>
				<td colspan="5" class="queryHeader">使用者新增</td>
			</tr>
			<tr>
				<th>使用者ID<span id="mustKeyInStar">**</span></th>
				<td><stripes:text id="createUserId" name="createUser.userId" size="15" maxlength="12" /></td>
				<th>姓名<span id="mustKeyInStar">**</span></th>
				<td colspan="2"><stripes:text id="createUserName" name="createUser.userName" size="15" maxlength="10" /></td>
			</tr>
			<tr>
				<th>電話</th>
				<td><stripes:text id="createUserPhoneNo" name="createUser.userPhoneNo" size="15" maxlength="12" /></td>
				<th>E-MAIL<span id="mustKeyInStar">**</span></th>
				<td colspan="2"><stripes:text id="createUserEmail" name="createUser.userEmail" size="30" maxlength="40" /></td>
			</tr>
			<tr>
				<th>啟用</th>
				<td>
					<stripes:select id="createEnabled" name="createUser.enabled">
	                      <stripes:option value="true" label="是"/>
	                      <stripes:option value="false" label="否"/>
                    </stripes:select>
				</td>
				<th>鎖定</th>
				<td colspan="2">
					<stripes:select id="createLocked" name="createUser.locked">
	                      <stripes:option value="false" label="否"/>
	                      <stripes:option value="true" label="是"/>
                    </stripes:select>
				</td>
			</tr>
			<tr>
				<th>憑證序號</th>
				<td><stripes:text id="createCertificateKey" name="createUser.certificateKey" size="30" maxlength="30"  /></td>
				<th>備註</th>
				<td colspan="2"><stripes:text id="createUserNote" name="createUser.userNote" size="30" maxlength="100"  /></td>
			</tr>
			<c:if test="${!actionBean.isBankGroupUser}">
				<tr>
					<th>可處理資料</th>
					<td colspan="4">
						<c:if test="${!empty actionBean.dealSecuritiesNos }">
						<input type="checkbox" name="checkboxAll" id="checkboxAll" value="全選"/>全選&nbsp;
						<c:forEach items="${actionBean.dealSecuritiesNos}" var="dealSecuritiesNosObj" varStatus="rowstat">
							<stripes:checkbox id="qryDealSecuritiesNos[${rowstat.index}]" name="qryDealSecuritiesNos[${rowstat.index}]" value="${dealSecuritiesNosObj.value}"/> <c:out value="${dealSecuritiesNosObj.label}" />&nbsp;
						</c:forEach>
						</c:if>
					</td>
				</tr>
				<tr>
					<th>所屬分公司</th>
					<td colspan="4">
						<stripes:select id="createSecurities_Pk" name="createUser.securities.securitiesPk">
							<c:forEach items="${actionBean.securitiesOptionList }" var="viewObj" varStatus="rowstat">
		                      <stripes:option value="${viewObj.securitiesPk }" label="${viewObj.securitiesName }"/>
		                    </c:forEach>  	                
	                     </stripes:select>
					</td>
				</tr>
			</c:if>
			<tr>
				<th>登入狀態</th>
				<td>
					
				</td>
				
				<th>上次登入時間</th>
				<td colspan="2"></td>
			</tr>
			<tr>
				<th>密碼有效時間</th>
				<td colspan="4"></td>
			</tr>
			<tr>
				<td colspan="5" class="queryFunction">
					<stripes:hidden name="createUser.userPk" />
					<stripes:hidden name="operation" />
					<stripes:submit id="doSaveBtn" name="doSave" value="確認" class="formBtn"/>
					<stripes:submit id="doCancelBtn" name="doCancel" value="取消" class="formBtn"/>
				</td>
			</tr>
		</table>
	</div>
		<!-- 查詢條件 -->
		<stripes:hidden id="hidden.qryGroupNoForm" name="qryGroupNoForm" />
		<stripes:hidden id="hidden.qryGroupNameForm" name="qryGroupNameForm" />
		<!-- 分頁信息 -->
		<stripes:hidden id="hidden.queryResult.pageNumber" name="queryResult.pageNumber" />
		<stripes:hidden id="hidden.queryResult.sortCriterion" name="queryResult.sortCriterion" />
		<stripes:hidden id="hidden.queryResult.sortDirection" name="queryResult.sortDirection" />
	</stripes:form>

<!-- 取消使用 -->	
<div style="display: none;">
<stripes:form id="hidden.queryUserForm" beanclass="com.feib.stms.action.Stms9006ActionBean" method="post" onsubmit="javascript: waitingDialog({});">
	<!-- 查詢條件 -->
	<stripes:hidden id="hidden.qryUserIdForm" name="qryUserIdForm" />
	<stripes:hidden id="hidden.qryUserNameForm" name="qryUserNameForm" />
	<!-- 分頁信息 -->
	<stripes:hidden id="hidden.queryResult.pageNumber" name="queryResult.pageNumber" />
	<stripes:hidden id="hidden.queryResult.sortCriterion" name="queryResult.sortCriterion" />
	<stripes:hidden id="hidden.queryResult.sortDirection" name="queryResult.sortDirection" />
	<stripes:submit id="hidden.doCancelBtn" name="doCancel" value="取消" class="formBtn"/>
</stripes:form>
</div>
</body>
</html>
